package com.hotel.project.demo.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.hotel.project.demo.dao.ICurdDao;
import com.hotel.project.demo.domain.BaseEntity;
import com.hotel.project.demo.service.base.ICurdService;


import java.io.Serializable;
import java.util.List;

public class CurdServiceImpl<T extends BaseEntity> extends ServiceImpl<ICurdDao<T>,T> implements ICurdService<T> {
    /**
     * 根据传入对象属性查找信息并分页
     * @param entity
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo listPage(T entity, int pageNum, int pageSize) {
        return PageHelper.startPage(pageNum,pageSize).doSelectPageInfo(() -> {
            baseMapper.selectByPage(entity);
        });
    }

    /**
     * 根据传入对象属性查找信息
     * @param entity
     * @return
     */
    @Override
    public List list(T entity) {
        return getBaseMapper().selectList(Wrappers.emptyWrapper());
    }

}
